package com.zlx.ssm.service.impl;

import com.zlx.ssm.mapper.EmployeeInfoMapper;
import com.zlx.ssm.model.EmployeeInfo;
import com.zlx.ssm.service.IUpdateService;
import com.zlx.ssm.vo.DateInfo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UpdateServiceImpl implements IUpdateService {

    @Autowired
    private EmployeeInfoMapper employeeInfoMapper;

    @Override
    public EmployeeInfo selectEmployeeInfo(String id) {

        EmployeeInfo employeeInfo = employeeInfoMapper.selectByPrimaryKey(Integer.valueOf(id));
        return employeeInfo;
    }

    @Override
    public int updateEmplo(DateInfo dateInfo) {

        EmployeeInfo emp = new EmployeeInfo();

        BeanUtils.copyProperties(dateInfo,emp);
        emp.setRoleName(dateInfo.getRoleName());
        emp.setId(Integer.valueOf(dateInfo.getId()));

        int i = employeeInfoMapper.updateByPrimaryKey(emp);

        return i;
    }

}
